﻿using System;
using System.Xml.Serialization;

using System.Windows;
using System.Windows.Media;

namespace SharpVectors.Renderers
{
    /// <summary>
    /// A value specifying the root resource element (<see cref="DrawingGroup"/>, <see cref="DrawingImage"/>).
    /// </summary>
    public enum ResourceModeType
    {
        /// <summary>
        /// Indicates the root element is not specified.
        /// </summary>
        None,
        /// <summary>
        /// Indicates the <see cref="DrawingGroup"/> as the root resource element.
        /// </summary>
        Drawing,
        /// <summary>
        /// Indicates the <see cref="DrawingImage"/> as the root resource element.
        /// </summary>
        Image
    }

    /// <summary>
    /// A value specifying the referencing or access resource dictionary (<c>DynamicResource</c>, <c>StaticResource</c>).
    /// </summary>
    public enum ResourceAccessType
    {
        /// <summary>
        /// Indicates the resource referencing type is not specified.
        /// </summary>
        None,
        /// <summary>
        /// Indicates the resource referencing is dynamic, <c>DynamicResource</c>.
        /// </summary>
        Dynamic,
        /// <summary>
        /// Indicates the resource referencing is static, <c>StaticResource</c>.
        /// </summary>
        Static
    }

    /// <summary>
    /// A value specifiying the resource key resolver type.
    /// </summary>
    public enum ResourceKeyResolverType
    {
        /// <summary>
        /// Indicates an unspecified or unknown resource key resolver.
        /// </summary>
        None,
        /// <summary>
        /// The default resource key resolver. On error, any defined resolver will fallback to the default resource resolver.
        /// </summary>
        Default,
        /// <summary>
        /// A dictionary-based resource key resolver.
        /// </summary>
        Dictionary,
        /// <summary>
        /// A user-defined <c>C#</c> code-based callback method for resolving the resource key. 
        /// It is compiled and run at runtime in memory.
        /// </summary>
        CodeSnippet,
        /// <summary>
        /// A custom or user-defined resource key resolver. It implements the <see cref="IResourceKeyResolver"/> interface.
        /// </summary>
        Custom
    }

    /// <summary>
    /// An interface for resolving the resource key of a resource object (<see cref="DrawingGroup"/>, <see cref="DrawingImage"/>)
    /// generated by the resource dictionary converter.
    /// </summary>
    public interface IResourceKeyResolver : IXmlSerializable
    {
        /// <summary>
        /// Gets a value specifying the resource key resolver type.
        /// </summary>
        /// <value>
        /// An enumeration of the type <see cref="ResourceKeyResolverType"/> specifying the type of the resource key resolver.
        /// </value>
        ResourceKeyResolverType ResolverType { get; }

        /// <summary>
        /// Gets a value specifying whether the resource key resolver is valid or not.
        /// </summary>
        /// <value>
        /// This is <see langword="true"/> if the resource resolver is valid, otherwise; it is <see langword="false"/>.
        /// </value>
        bool IsValid { get; }

        /// <summary>
        /// This signals the start of a resource key resolving process.
        /// </summary>
        void BeginResolve();

        /// <summary>
        /// This signals the end of a resource key resolving process.
        /// </summary>
        void EndResolve();

        /// <summary>
        /// Generates the resource key to be applied to the specified resource object, created from the file name 
        /// and from the specified source (directory).
        /// </summary>
        /// <param name="resource">The target resource object (<see cref="DrawingGroup"/>, <see cref="DrawingImage"/>) </param>
        /// <param name="index">The index of the resource file.</param>
        /// <param name="fileName">The file name of the SVG file without the extension.</param>
        /// <param name="fileSource">The source directory of the SVG file.</param>
        /// <returns>
        /// A <see cref="String"/> containing the key to be used to identify the specified resource. This must be at least
        /// 3 characters and less than 255 characters.
        /// </returns>
        string Resolve(DependencyObject resource, int index, string fileName, string fileSource);
    }
}
